const express = require("express");
const route = express.Router();
//引入权限校验中间件
const isLoginMiddle = require("../middleware/isLoginMiddle")

const advModel = require("../db/modle/advModel")

//主要是为了书写一个接口,使用我们封装好的权限验证中间件
route.get("/advList", isLoginMiddle, async (req, res) => {
  //查询所有的广告列表集合的数据
  try {
    const findResult = await advModel.find({});
    res.send({
      code: 10000,
      msg: "查询成功",
      data: findResult
    })
  } catch (e) {
    console.log("查询广告列表异常" + e.message);
    res.send({
      code: 10001,
      msg: "查询广告列表异常" + e.message,
      data: null
    })
  }

})

module.exports = route;